package com.atbeifang.transfer.controller;

import java.sql.Timestamp;
import java.util.List;
import java.util.Map;


import com.atbeifang.common.bean.PageParamVo;
import com.atbeifang.common.bean.PageResultVo;
import com.atbeifang.common.bean.ResponseVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.atbeifang.transfer.entity.TransferEntity;
import com.atbeifang.transfer.service.TransferService;

/**
 * 
 *
 * @author 小灰灰
 * @email huihui@atguigu.com
 * @date 2021-11-14 01:02:46
 */
@Api(tags = " 管理")
@RestController
@RequestMapping("transfer/transfer")
public class TransferController {

    @Autowired
    private TransferService transferService;

    /**
     * 列表
     */
    @GetMapping
    @ApiOperation("分页查询")
    public ResponseVo<PageResultVo> queryTransferByPage(PageParamVo paramVo) {
        PageResultVo pageResultVo = transferService.queryPage(paramVo);
        return ResponseVo.ok(pageResultVo);
    }


    /**
     * 信息
     */
    @GetMapping("{batchId}")
    @ApiOperation("详情查询")
    public ResponseVo<TransferEntity> queryTransferById(@PathVariable("batchId") Long batchId) {
        TransferEntity transfer = transferService.getById(batchId);

        return ResponseVo.ok(transfer);
    }

    //===============================================================


    /**
     * 保存
     */
    @PostMapping
    @ApiOperation("保存")
    public ResponseVo<Object> save(@RequestBody TransferEntity transfer) {
        transferService.save(transfer);

        return ResponseVo.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    @ApiOperation("修改")
    public ResponseVo update(@RequestBody TransferEntity transfer) {
        transferService.updateById(transfer);

        return ResponseVo.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    @ApiOperation("删除")
    public ResponseVo delete(@RequestBody List<Long> batchIds) {
        transferService.removeByIds(batchIds);

        return ResponseVo.ok();
    }


}
